/**
 * 用户笔记管理
 * @project readnote
 * @author huxh
 * @date 2012-5-15
 **/
package com.readnote.admin.book;

import com.cr.backbone.action.AppBaseActionSupport;
import com.readnote.book.model.UserNote;
import com.readnote.book.service.UserNoteService;

public class UserNoteManageAction extends AppBaseActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1179031234511250745L;
	
	private Long[] ids;//数据更新主键集合
	private UserNote userNote;

	
	private UserNoteService userNoteService;
	
	/***
	 * 查看 userNote list
	 */
	public String index(){
		page = userNoteService.getPage(getQuery(), page);
		return INDEX;
	}
	
	/***
	 * 查看 userNote list
	 */
	public String query(){
		page = userNoteService.getPage(getQuery(), page);
		return INDEX;
	}
	
	/**
	 * 进入userNote更新页面
	 */
	public String input(){
		if(ids!=null && ids.length!=0)
			userNote = userNoteService.get(ids[0]);
		return INPUT;
	}
	
	/**
	 * 保存（新建\更新）
	 * @methodDescribe 
	 * @return
	 * @author xianghua.hu
	 * @date 2012-5-15
	 */
	public String save(){
		if(userNote==null || userNote.isNullRow()){
			userNoteService.save(userNote);
		}else{
			UserNote _userNote = userNoteService.get( userNote.getId() );
			
			userNoteService.update(_userNote);
		}
		return SUCCESS;
	}

	public Long[] getIds() {
		return ids;
	}

	public void setIds(Long[] ids) {
		this.ids = ids;
	}

	public UserNote getUserNote() {
		return userNote;
	}

	public void setUserNote(UserNote userNote) {
		this.userNote = userNote;
	}

	public UserNoteService getUserNoteService() {
		return userNoteService;
	}

	public void setUserNoteService(UserNoteService userNoteService) {
		this.userNoteService = userNoteService;
	}
	
	

	
}
